<template>
  <div class="product-add mt30">
    <!--form表单-->

    <el-form size="small" ref="form" :model="form" label-width="200px">
      <el-form-item label="申请协议">
        <div class="edit_container">
          <Uediter
            :text="form.license"
            :config="ueditor.config"
            ref="ue"
            @contentChange="contentChangeFunc"
            :id="ueditor.id"
          >
          </Uediter>
        </div>
      </el-form-item>

      <!--提交-->
      <div class="common-button-wrapper">
        <el-button
          size="small"
          type="primary"
          @click="onSubmit"
          :loading="loading"
          >提交</el-button
        >
      </div>
    </el-form>
  </div>
</template>

<script>
import PlusApi from "@/api/plus.js";
import Uediter from "@/components/UE.vue";
export default {
  components: {
    Uediter,
  },
  data() {
    return {
      /*form表单数据*/
      form: {},
      /*是否正在加载*/
      loading: false,
      /*富文本配置*/
      ueditor: {
        text: "",
        config: {
          initialFrameWidth: 400,
          initialFrameHeight: 500,
        },
        id: "agent_license",
      },
    };
  },
  props: {
    settingData: Object,
  },
  created() {
    this.form = this.settingData.license;
  },

  methods: {
    /*获取富文本内容*/
    contentChangeFunc(e) {
      this.form.license = e;
    },
    /*提交表单*/
    onSubmit() {
      let self = this;
      self.loading = true;
      let params = self.form;
      PlusApi.license(params, true)
        .then((data) => {
          self.loading = false;
          ElMessage({
            message: "设置成功",
            type: "success",
          });
        })
        .catch((error) => {
          self.loading = false;
        });
    },
  },
};
</script>

<style scoped>
::v-deep .tiny-rich-text-editor__container {
  height: auto;
}
</style>
